package com.gitee.wsl.struct.product.money

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.InternalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.buildSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
//
//object MoneySerializer : KSerializer<Money> {
//
//    // we can autogenerate a serializer which will retain annotations of serialized class
//    //@OptIn(ExperimentalSerializationApi::class)
//    //@Serializer(forClass = Money::class)
//    //private object AutoSerializer
//
//    /*@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
//    public override val descriptor: SerialDescriptor = buildSerialDescriptor(
//        serialName = AutoSerializer.descriptor.serialName,
//        kind = PrimitiveKind.STRING
//    ) {
//        annotations = AutoSerializer.descriptor.annotations
//    }*/
//
//    override fun serialize(encoder: Encoder, value: Money) {
//        encoder.encodeString(value.toString())
//    }
//
//    override val descriptor: SerialDescriptor
//        get() = TODO("Not yet implemented")
//
//    override fun deserialize(
//        decoder: Decoder
//    ): Money = Money(decoder.decodeString())
//
//}
//
//public object MoneyRatioSerializer : KSerializer<Money.Ratio> {
//
//    // we can autogenerate a serializer which will retain annotations of serialized class
//    //@OptIn(ExperimentalSerializationApi::class)
//    //@Serializer(forClass = Money.Ratio::class)
//    //private object AutoSerializer
//
//    @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
//    /*public override val descriptor: SerialDescriptor = buildSerialDescriptor(
//        serialName = AutoSerializer.descriptor.serialName,
//        kind = PrimitiveKind.STRING
//    ) {
//        annotations = AutoSerializer.descriptor.annotations
//    }*/
//
//    override fun serialize(encoder: Encoder, value: Money.Ratio) {
//        encoder.encodeString(value.toString())
//    }
//
//    override val descriptor: SerialDescriptor
//        get() = TODO("Not yet implemented")
//
//    override fun deserialize(
//        decoder: Decoder
//    ): Money.Ratio = Money.Ratio(decoder.decodeString())
//
//}
